﻿<%@ Page Language="C#"  %>
<%@ Register Assembly="PeekEditor" Namespace="PeekEditor" TagPrefix="PeekEditor" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script> 
    <link href="../../Styles/jquery.validate.css" rel="stylesheet" type="text/css" /> 
    <script src="../../Scripts/jquery.validate.js" type="text/javascript"></script> 
     <script src="../../Scripts/jquery.validator.messages.js" type="text/javascript"></script>     
    <script type="text/javascript" src="../../Scripts/jquery.query.js"></script>
    <script src="../js/blockUI.js" type="text/javascript"></script>
</head>
<body>
     <form id="form1" runat="server"   method="post" action="../AjaxHandler/AdvertisementEditHandler.ashx?action=Edit">
    <div>
        <table>
           
            <tr>
                <td>
                    标题
                </td>
                <td>
                    <input type="text" id="title" name="title"  size="80"/>
                </td>
            </tr>
            <tr>
                <td>
                    正文
                </td>
                <td>
                    <PeekEditor:CKEditorControl ID="content" runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    备注
                </td>
                <td>
                    <textarea id="remark" rows="5" cols="80" name="remark" ></textarea>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input type="submit" id="btn_Save" value="保 存" /><input type="button" id="btn_Back" value="返 回"  onclick="javascript:history.back();" />
                </td>
            </tr>
        </table>
    </div>
    <input id="hidCode" name="hidCode" type="hidden" value="-1" />
    </form>
     <script type="text/javascript">
         $(document).ready(function () {
             var code = $.query.get("code");
             $("#hidCode").val(code);
             function SetEditorContents(EditorName, ContentStr) { var oEditor = CKEDITOR.instances[EditorName]; oEditor.setData(ContentStr); }
             var BindData = function () {

                 if (code != "-1") {
                     $.blockUI({ message: "<h2>数据加载中.......</h2>", css: { width: "300px", height: "50px"} });
                     $.post("../AjaxHandler/AdvertisementEditHandler.ashx", { action: "Get", hidCode: code }, function (data) {
                         $("#title").val(data.Title);
                         $("#remark").val(data.Remark);
                         SetEditorContents("content", data.Content);
                         $.unblockUI();
                     });
                   
                 }
               
             }
             BindData();
             $("#form1").validate({
                 rules: {
                     title: {
                         required: true,
                         remote: {
                             type: "POST",
                             url: "../AjaxHandler/CheckAdvertisementTitle.ashx",
                             data: { name: function () { return $("#name").val(); }, id: code }
                         }
                     }
                 },
                 messages:
                    {
                        title: { required: "请输入标题", remote: "该标题已存在！" }
                    }
             });

         });
    </script>
</body>
</html>
